//	---------------------------------------------------------------------------
//	dark-matter-data
//	Copyright (c) 2012 dark-matter-data committers
//	---------------------------------------------------------------------------
//	This program is free software; you can redistribute it and/or modify it
//	under the terms of the GNU Lesser General Public License as published by the
//	Free Software Foundation; either version 3 of the License, or (at your
//	option) any later version.
//	This program is distributed in the hope that it will be useful, but WITHOUT
//	ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//	FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
//	more details.
//	You should have received a copy of the GNU Lesser General Public License along
//	with this program; if not, see <http://www.gnu.org/licenses/lgpl.html>.
//	---------------------------------------------------------------------------
package org.dmd.examples.contacts.server.plugins;

import java.util.UUID;

import org.dmd.dmc.DmcClassInfo;
import org.dmd.dmc.types.UUIDName;
import org.dmd.dmp.server.servlet.base.cache.NameGeneratorIF;
import org.dmd.dmw.DmwNamedObjectWrapper;
import org.dmd.examples.contacts.server.generated.dmw.ContactDMW;
import org.dmd.examples.contacts.shared.generated.dmo.ContactsDMSAG;


public class ContactNameGenerator implements NameGeneratorIF {

	@Override
	public DmcClassInfo usedForClass() {
		return(ContactsDMSAG.__Contact);
	}

	@Override
	public void createNameForObject(DmwNamedObjectWrapper object) {
		ContactDMW contact = (ContactDMW) object;
		UUID	uuid = UUID.randomUUID();
		UUIDName uuidName = new UUIDName(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits());
		contact.setUuidName(uuidName);
	}

}
